<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <title>管理员登陆</title>         

        <link rel="stylesheet" type="text/css" href="/static/css/login.css" />          

    </head>

    <body> 

        <div class="form-wrap">

            <div class="login">

                <form>

                    <h1>Welcome Home!</h1>

                    <label>Username / 用户名</label>

                    <input type="text" name="username" id="username" placeholder="Enter your account">

                    <label>Password / 密码</label>

                    <input type="password" name="password" id="password" placeholder="Enter your password" required>

                    <label>VerifyCode / 验证码</label>

                    <input type="text" name="code" maxlength="4" id="code" placeholder="请输入验证码">

                    <div class="loginButton" id="loginBtn">Log in / 登录</div>

                    <div class="verify-code">

                        <img src="{:captcha_src()}" id="codeImg"  onclick="this.src=this.src+'?'"  alt="验证码"  style="margin-top: 10px"/>

                    </div>

                    <span> <a href="javascript:;" class="maker">Make by : author</a></span>

                </form> 

            </div>

        </div>

    </body>

    <script src="/static/js/jquery.min.js"></script>

    <script src="/static/layui/layer.js"></script>

    <script type='text/javascript'>

        $("#loginBtn").click(function(){

            var username = $("#username").val();

            var password = $("#password").val();

            var code     = $("#code").val();

            if (username == '') {

                layer.msg('请输入用户名');

                return;

            }

            if (password == '') {

                layer.msg('请输入登录密码');

                return;

            }

            if (code == '') {

                layer.msg('请输入验证码');

                return;

            }

            var post_data = {

                "username":username,

                "password":password,

                "code":code

            };

            $.ajax({

                url:"/admin/login/checkInfo",

                type:"POST",

                data:post_data,

                success:function(ret){

                    if (ret.code == 0) {

                        window.location.href = "/admin/index/index";

                    }

                    if (ret.code == 1) {

                        layer.msg(ret.msg);

                    }

                }

            });

        });

        $(document).keypress(function (e) {

            // 回车键事件  

            if (e.which == 13) {

                $("#loginBtn").click();

            }

        });

    </script>

</html>